%% @private
-module(cn2p_product_catalog_service_app).
-behaviour(application).

%% API.
-export([start/2]).
-export([stop/1]).

%% API.
start(_Type, _Args) ->

  %% {HostMatch, list({PathMatch, Handler, Opts})}
	Dispatch = cowboy_router:compile([
		{'_', [
			{"/api/product", product_handler, []},
      {"/api/product/tags", tag_handler, []},
      {"/api/product/delete", product_handler, []},
      {"/api/product/search/:search_type", search_handler, []},
      {"/api/product/:product_id", product_handler, []},
      {"/api/product/:product_id/details", product_details_handler, []},
      {"/api/product/:product_id/reviews/[:review_id]", review_handler, []}
		]}
	]),
	{ok, _} = cowboy:start_http(http, 100, [{port, 8080}], [
		{env, [{dispatch, Dispatch}]}
	]),
	cn2p_product_catalog_service_sup:start_link().

stop(_State) ->
	ok.
